<!--
 * @Description: 编辑按钮
 * @Version: 1.0
 * @Author: Yuanjy
 * @Date: 2020-03-13 19:56:08
 * @LastEditors: Yuanjy
 * @LastEditTime: 2020-05-13 10:20:04
 -->
<template>
  <div>
    <el-button size="mini" type="success" @click="to">编辑</el-button>
    <eForm ref="form" :sup-this="supThis" :is-add="false"/>
  </div>
</template>
<script>
import eForm from './form'
import { isJson } from '@/utils'

export default {
  components: { eForm },
  props: {
    data: {
      type: Object,
      required: true
    },
    supThis: {
      type: Object,
      required: true
    }
  },
  methods: {
    to() {
      const _this = this.$refs.form
      _this.form = {
        id: this.data.id,
        type: this.data.type.toString(),
        sub_type: this.data.sub_type.toString(),
        send_handle: this.data.send_handle,
        config: this.data.config,
      }
      if (isJson(this.data.config)) {
        _this.jsonEditor = true
        _this.form.config = JSON.parse(this.data.config)
      }
      _this.dialog = true
      _this.initParams()
    }
  }
}
</script>

<style scoped>
  div{
    display: inline-block;
    margin-right: 3px;
  }
</style>
